<template>
   <div id="birt" v-loading="loading">
      <v-table
          :page="page"
          :pageSize="pageSize"
          :tableConfig="tableConfig"
          :tableData="tableData"
          :total="total"
          @findData="getTableData"
          @getTableData="getTableData"
          @searhData="searhData"
          @selectData="selectData"
          @setdialog="setdialog"
          @upData="getTableData"
          ref="table"
      ></v-table>
   </div>
</template>

<script type="text/ecmascript-6">
import drawer from "./deawer/Deawer"
import tableTitle from "commons/TableTitle";
import table from "commons/Table";
import baseMixin from "@/mixins/BaseMixin";

export default {
   name: "birt",
   mixins: [baseMixin],
   data() {
      return {
         loading: false,
         tableConfig: [
            {
               label: this.$t('manage.rptTitle'),
               prop: "rpt_title",
               input: "input",
            },
            {
               label:  this.$t('app.remark'),
               prop: "comments",
               input: "input",
            },
         ],
         tableData: [],
         pageSize: 10,
         page: 1,
         total: 0,
         tableSelectData: [],
         tableSearhData: {},
      };
   },
   methods: {
      //选中的内容
      selectData(data) {
         this.tableSelectData = data;
      },
      async getTableData(page, data) {
         try {
            this.loading = true;
            let res = await this.$api.post(`/birt/${page}`, data);
            
               this.tableData = res.page.list;
               this.page = res.page.curPage;
               this.pageSize = res.page.pageSize;
               this.total = res.page.total;
            
         } catch (e) {
            this.$message.error(e);
         } finally {
            this.loading = false;
         }
      },
      //搜索的值
      searhData(data, up) {
         if (!up) {
            this.tableSearhData = data;
         } else {
            this.tableSearhData = data;
            this.getTableData(1, this.tableSearhData);
         }
      },

      //设置弹框
      setdialog(data) {
         let url = sessionStorage.getItem("url");
         let birt = sessionStorage.getItem("birtUrl");
         this.$router.push({name: 'birtDeawer', params: {url: `${url}${birt}${data.birtrpt_url}`}});
      },

   },
   mounted() {
      this.$store.commit("setSkip", {});
      this.$store.commit("setRouteData", {});
      this.$store.commit("setNewFlag", false);
      this.getTableData(1, {});
   },
   watch: {},
   components: {
      "v-tableTitle": tableTitle,
      "v-table": table,
      "v-drawer": drawer
   }
};
</script>

<style scoped>
#birt {
   width: 100%;
   height: 99%;
   padding-top: 6px;
}
</style>
